package edu.suda.xsap.service.impl;

import edu.suda.xsap.dto.LogDto;
import edu.suda.xsap.dto.convert.LogConvert;
import edu.suda.xsap.entity.Log;
import edu.suda.xsap.mapper.LogMapper;
import edu.suda.xsap.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private LogConvert logConvert;

    @Autowired
    private LogMapper logMapper;

    @Override
    public void save(Log log) {
        logMapper.save(log);
    }

    @Override
    public List<LogDto> findAll() {
        //
        List<Log> logs = logMapper.findAll();
        //要把这个List<Log>转换成List<LogDto>
        return logConvert.toDtoList(logs);
    }
}
